<?php
########################################################################################
# Empresa :     Tecnopac Informatica;                                                  #
# Autor:        Deiverson Pacheco;                                                     #
# Data Criação: 18/12/2010;                                                            #
########################################################################################
session_start();
header("Cache-control: private");
include_once("../../includes/session.php");


//Linha para formatação de caracteres com acentuação
header("Content-Type: text/html; charset=ISO-8859-1",true);


//======================================================================================
//==> Include obrigatórias no script
//======================================================================================
include_once('../../includes/classes/class.TemplatePower.php');
include_once('../../includes/classes/class.Conexao.php');
include_once('../../includes/classes/class.Geral.php');

//======================================================================================
//==> Inicializar Classes
//======================================================================================
$not  = new Persist;
$data = new getData;
$cor  = new ColorTr;
$util = new Util;
$vld  = new ValidarDados;
$sql  = new SqlInjection;

//======================================================================================
//==> Instanciar TemplatePower para juntar o PHP + HTML
//======================================================================================
$tpl  = new TemplatePower('../../html/vendas/popup_cadastro_pedido.html');
$tpl->prepare();


//======================================================================================
//==> Recebe variaveis de pesquisa
//======================================================================================
$busca  = @$_GET['busca'];

$sql_busca = '';
if($busca != ''){
   $busca = $sql->tratar($busca,50);
   $sql_busca = " and nome_razao like '%$busca%' ";
}

$cont   = 1;
$not->sql = "select id, nome_razao, doc, dt_nascimento, rg, residencial, comercial, celular, cep, endereco, numero, complemento, bairro, cidade, uf, email
			 from cadastro
			 where ativo = '1' $sql_busca order by nome_razao asc";
			 
if($not->ler()>0){
	while($not->ini()){
		$tpl->newBlock('LOOP');
		$tpl->assign('cont',$cont);
		$cont++;

		
		$tpl->assign('id', $not->id);
		$tpl->assign('par_id',$not->id);
		$tpl->assign('nome', $not->nome_razao);
		$tpl->assign('cpf', $not->doc);
		$tpl->assign('dnas', $data->getDataFormatada($not->dt_nascimento));
		$tpl->assign('rg', $not->rg);
		$tpl->assign('t1', $not->residencial);
		$tpl->assign('t2', $not->comercial);
		$tpl->assign('cel', $not->celular);
		$tpl->assign('cep', $not->cep);
		$tpl->assign('logradouro', $not->endereco);
		$tpl->assign('numero', $not->numero);
		$tpl->assign('compl', $not->complemento);
		$tpl->assign('bairro', $not->bairro);
		$tpl->assign('cidade', $not->cidade);
		$tpl->assign('uf', $not->uf);
		$tpl->assign('email', $not->email);
		$tpl->assign('cor', $cor->altColor());		
		
	}
}
$tpl->goToBlock('_ROOT');

//======================================================================================
//==> Enviar página unificada PHP + HTML
//======================================================================================
$tpl->showUnAssigned( false );  // para debug. na hora de publicar, setar para false
$tpl->printToScreen();
?>